package com.example.chapter13;


import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;

/*
 * 13.3.案例实施-复制文件
 * */
public class FileCopyExample {

    public static void main(String[] args) {
        String sourceFilePath = "path/to/your/source.txt";
        String targetFilePath = "path/to/your/target.txt";
        Path sourcePath = Paths.get(sourceFilePath);
        Path targetPath = Paths.get(targetFilePath);
        try {
            Files.copy(sourcePath, targetPath, StandardCopyOption.REPLACE_EXISTING);
            System.out.println("File copied successfully");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
